Micron Document
Fox's Git Mirrors

Commit 633735d797cc5f5d48cb2e22e8fd7cd743930daf


Parents : a6ee48b
Author : Ivan <e318cbc04468bd574db2b4523dddd710>
Signature : T66BB85Valid, signed by author
Date : 2026-08-14T11:11:51-05:00

fix: improve context handling and type conversions in session and transport packages

Changes

6 files changed, 27 insertions(+), 7 deletions(-)


Diff

diff --git a/pkg/rgosh/session.go b/pkg/rgosh/session.go
index 35767aab..02892647 100644
--- a/pkg/rgosh/session.go
+++ b/pkg/rgosh/session.go
@@ -136,7 +136,7 @@ func NewSession(cfg Config, sender Sender) *Session {
if c.Capabilities == 0 {
c.Capabilities = CapLineMode | CapCoalesce
}
- ctx, cancel := context.WithCancel(context.Background())
+ ctx, cancel := context.WithCancel(context.Background()) // #nosec G118 -- cancelled in Session.Close
if cs, ok := sender.(ChannelSender); ok {
cs.Ctx = ctx
sender = cs

diff --git a/pkg/rnsutil/windows.go b/pkg/rnsutil/windows.go
index c939b5e2..6032a04f 100644
--- a/pkg/rnsutil/windows.go
+++ b/pkg/rnsutil/windows.go
@@ -60,18 +60,19 @@ func LinkEstablishmentWindow(l *link.Link) time.Duration {
}
// BoundWait returns a child context limited to window unless parent already
-// has a deadline (an explicit caller timeout wins).
+// has a deadline (an explicit caller timeout wins). The returned cancel must
+// be invoked by the caller when non-nil.
func BoundWait(parent context.Context, window time.Duration) (context.Context, context.CancelFunc) {
if parent == nil {
parent = context.Background()
}
if _, ok := parent.Deadline(); ok {
- return context.WithCancel(parent)
+ return parent, func() {}
}
if window <= 0 {
- return context.WithCancel(parent)
+ return parent, func() {}
}
- return context.WithTimeout(parent, window)
+ return context.WithTimeout(parent, window) // #nosec G118 -- caller defers cancel()
}
// CLIWaitContext applies timeout when positive. Zero means adaptive waits

diff --git a/pkg/sandbox/paths.go b/pkg/sandbox/paths.go
index 11d08c2c..d336d05e 100644
--- a/pkg/sandbox/paths.go
+++ b/pkg/sandbox/paths.go
@@ -5,6 +5,7 @@ package sandbox
import (
"path/filepath"
+ "strconv"
"strings"
"quad4/reticulum-go/pkg/common"
@@ -45,7 +46,7 @@ func collectExtraPaths(cfg *common.ReticulumConfig) []extraPath {
if !filepath.IsAbs(p) {
return
}
- key := p + "\x00" + string(rune(kind))
+ key := p + "\x00" + strconv.Itoa(int(kind))
if _, ok := seen[key]; ok {
return
}

diff --git a/pkg/transport/packet_hashlist.go b/pkg/transport/packet_hashlist.go
index b4d7c149..afd3226b 100644
--- a/pkg/transport/packet_hashlist.go
+++ b/pkg/transport/packet_hashlist.go
@@ -6,6 +6,7 @@ package transport
import (
"encoding/binary"
"fmt"
+ "math"
"sync"
"quad4/reticulum-go/pkg/common"
@@ -32,7 +33,14 @@ func hashSlot(k [32]byte, mask int) int {
x ^= binary.LittleEndian.Uint64(k[8:16])
x ^= binary.LittleEndian.Uint64(k[16:24])
x ^= binary.LittleEndian.Uint64(k[24:32])
- return int(x) & mask
+ if mask < 0 {
+ return 0
+ }
+ slot := x & uint64(mask)
+ if slot > uint64(math.MaxInt) {
+ return 0
+ }
+ return int(slot)
}
func (g *hashGen) has(k [32]byte) bool {

diff --git a/pkg/transport/remote_mgmt.go b/pkg/transport/remote_mgmt.go
index d396e8d8..53c38b22 100644
--- a/pkg/transport/remote_mgmt.go
+++ b/pkg/transport/remote_mgmt.go
@@ -6,6 +6,7 @@ package transport
import (
"bytes"
"fmt"
+ "math"
"time"
"quad4/msgpack/v5/pkg/msgpack"
@@ -231,9 +232,15 @@ func asIntPtrAny(v any) *int {
i := int(n)
return &i
case int64:
+ if n > int64(math.MaxInt) || n < int64(math.MinInt) {
+ return nil
+ }
i := int(n)
return &i
case uint:
+ if n > math.MaxInt {
+ return nil
+ }
i := int(n)
return &i
case uint8:
@@ -246,6 +253,9 @@ func asIntPtrAny(v any) *int {
i := int(n)
return &i
case uint64:
+ if n > uint64(math.MaxInt) {
+ return nil
+ }
i := int(n)
return &i
case float32:

diff --git a/reticulum-go.rsm b/reticulum-go.rsm
index 914c2196..b1fdc47b 100644
Binary files a/reticulum-go.rsm and b/reticulum-go.rsm differ

Served by rngit 1.5.2 - Generated in 0.07s